package com.osmino.contacts.view.list;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.osmino.contacts.model.contacts.IContact;

public class ContactListView extends ListView implements android.widget.AdapterView.OnItemClickListener{
	
	List<IContact> contacList;
	ContactListAdapter adapter;
	
	
	public ContactListView(Activity activity, ListViewClient client) {
		super(activity);
		setDividerHeight(0);
		setVerticalFadingEdgeEnabled(true);
		contacList = new ArrayList<IContact>();
		setOnItemClickListener(this);
		adapter = new ContactListAdapter(activity);
		setAdapter(adapter);
	}
	
	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		contacList.get(position);
	};
	
	public void fill(List<IContact> list) {
		contacList.clear();
		contacList.addAll(list);
		adapter.refreshList(contacList);
	}
	
	public interface ListViewClient{
		public void onContactClick(IContact contact);
	}
}
